<template>
  <view class="container">
    <button @click="handleJumpSetting">跳转设置</button>
    <button @click="handleClearCache">清除缓存</button>
    <button @click="handleLaunchMiniProgram">打开微信小程序</button>
    <button @click="handleOpenHuaweiMarket">打开应用市场</button>
    <button @click="handleTextShare">文本分享</button>
    <button @click="handleImageShare">图片分享</button>
    <button @click="handleGetParam">获取参数</button>
  </view>
</template>


<script setup lang="ts">
import { ref, onMounted } from 'vue'
import{calcCache,
  clearCache,
  jumpSetting,
  launchMiniProgram,
  openHuaweiAppMarket,
  textshare,
  imageshare,
  getParam,

  } from '@/uni_modules/fer-harmony'
import { windowUtils } from '../../uni_modules/fer-harmony/utssdk/app-harmony/windowUtils'
//防截屏
  onShow(() => {
    // @ts-ignore
    const context: common.UIAbilityContext = getContext() // 只在HarmonyOS生效
    windowUtils.setWindowPrivacyModeInPage(context, true)
  })
  
const cacheSize = ref('')
const paramValue = ref('')
async function handleGetCache() {
  cacheSize.value = await calcCache()
}

function handleClearCache() {
  clearCache()
  cacheSize.value = ''
}

function handleJumpSetting() {
  jumpSetting()
}

function handleLaunchMiniProgram() {
  launchMiniProgram()
}

function handleOpenHuaweiMarket() {
  openHuaweiAppMarket()
}

function handleTextShare() {
  textshare()
}

function handleImageShare() {
  imageshare()
}
function handleGetParam() {
  const want = {
    uri: 'example://open?foo=bar&token=abc123'
  }
  const key = 'token'
  const value = getParam(want, key)
  paramValue.value = value ?? '未找到参数'
}

	function onShow(arg0: () => void) {
		throw new Error('Function not implemented.')
	}
</script>

<style>
.container {
  display: flex;
  flex-direction: column;
  gap: 20rpx;
  padding: 40rpx;
}
button {
  padding: 20rpx;
  background-color: #007aff;
  color: white;
  border-radius: 10rpx;
}
</style>
